package simple_factory

import (
	"errors"
	"fmt"
	"strings"
)

var DefaultLightFactory = newLightFactory()

type tLightFactory struct {
}

func newLightFactory() ILightFactory {
	return &tLightFactory{}
}

func (me *tLightFactory) Create(info *LightInfo) (error, ILight) {
	switch strings.ToLower(info.sVendor) {
	case "mijia":
		return nil, newMijiaLight(info)
	case "redmi":
		return nil, newRedmiLight(info)
	default:
		return errors.New(fmt.Sprintf("unsupported vendor: %s", info.sVendor)), nil
	}
}
